package org.zhadoop.stream.cql.semanticanalyzer.parser.context;

import org.zhadoop.stream.cql.exception.SemanticAnalyzerException;
import org.zhadoop.stream.cql.semanticanalyzer.analyzecontext.expressiondesc.ExpressionDescribe;
import org.zhadoop.stream.cql.semanticanalyzer.parsecontextreplacer.ParseContextReplacer;
import org.zhadoop.stream.cql.semanticanalyzer.parsecontextwalker.ParseContextWalker;

/**
 * fieldExpression语法解析内容
 * 
 * @author zwd
 *
 */
public class FieldExpressionContext extends BaseExpressionParseContext {

	private String streamNameOrAlias;

	private BaseExpressionParseContext atomExpression;

	public String getStreamNameOrAlias() {
		return streamNameOrAlias;
	}

	public void setStreamNameOrAlias(String streamNameOrAlias) {
		this.streamNameOrAlias = streamNameOrAlias;
	}

	public BaseExpressionParseContext getAtomExpression() {
		return atomExpression;
	}

	public void setAtomExpression(BaseExpressionParseContext atomExpression) {
		this.atomExpression = atomExpression;
	}

	@Override
	public void walkChildAndReplace(ParseContextReplacer replacer) {
		// TODO Auto-generated method stub

	}

	@Override
	protected ExpressionDescribe createExpressionDesc() throws SemanticAnalyzerException {
		if(streamNameOrAlias != null){
			atomExpression.setLeftExpression(this);
		}
		return atomExpression.createExpressionDesc(getSchemas());
	}

	@Override
	public String toString() {
		return streamNameOrAlias == null ? atomExpression.toString()
				: streamNameOrAlias + "." + atomExpression.toString();
	}

	@Override
	protected void walkChild(ParseContextWalker walker) {
		// TODO Auto-generated method stub

	}
	

}
